﻿using System;
using System.Windows.Forms;

namespace WPlayer
{
    public partial class Form2 : Form
    {
        Func<string, bool> check;

        public Form2(Func<string, bool> func)
        {
            InitializeComponent();
            this.check = func;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (this.textBox1.TextLength == 0)
            {
                MessageBox.Show(this, "密码不能为空！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textBox1.Focus();
                return;
            }
            if (!this.check(this.textBox1.Text))
            {
                MessageBox.Show(this, "密码错误！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textBox1.Focus();
                return;
            }
            this.DialogResult = DialogResult.OK;
        }
    }
}
